{% assign title = include.title | default: "" %}
{% assign featured_width = include.width | default: "" %}
{% assign featured_height = include.height | default: "" %}
{% assign include_maxwidth = include.maxwidth %}
{% assign include_style = include.style | default: "center" %}
{% assign include_tag = include.tag | default: "" %}
{% if title != "" %} <h3>{{ title }}</h3>{% endif %}
{%- include gallery/begin.html style=include_style -%}
{% assign item_num = 0 %}
{%- for item in site.data.featured -%}
  {%- assign item_title = item['@title'] -%}
  {%- assign item_tags = item['@tags'] | default: "" -%}
  {%- if item_title != "" and item_tags contains include_tag -%}
    {% assign item_num = item_num | plus:1 %}
    {%- assign item_link = item['@permalink'] -%}
    {%- assign item_id = item_link | slugify | prepend: "featured-" -%}
    {%- assign item_preview = item['@preview'] | default: "/documents/covers/default.jpg" -%}
    {%- if item_preview == ".jpg" or item_preview == ".png" -%}{%- capture item_preview -%}{{ item_link }}{%- if featured_width == "200" -%}images/thumbnail{%- else -%}images/screenshot{%- endif -%}{{ item_preview }}{%- endcapture -%}{%- endif -%}
    {%- assign item_width = item['@width'] | default: featured_width -%}
    {%- assign item_height = item['@height'] | default: featured_height -%}
    {%- include gallery/image.html id=item_id image=item_preview link=item_link title=item_title width=item_width height=item_height maxwidth=include_maxwidth -%}
  {%- endif -%}
{%- endfor -%}
{%- include gallery/end.html -%}
{%- if item_num == 0 %}
  <p>No Featured Items found under {{ title | default: include_tag }}</p>
{%- endif -%}
